const { override, addWebpackAlias, addLessLoader } = require("customize-cra");
const rewireReactHotLoader = require("react-app-rewire-hot-loader");
const path = require("path");

module.exports = override(
  // 默认路径设置
  addWebpackAlias({
    // 组件
    "@/components": path.resolve(__dirname, "src/components"),
    // 页面
    "@/pages": path.resolve(__dirname, "src/pages"),
    // 资源
    "@/assets": path.resolve(__dirname, "src/assets"),
  }),
  (config, env) => {
    config = rewireReactHotLoader(config, env);
    return config;
  },
  // less模块加载
  addLessLoader({
    strictMath: true,
    noIeCompat: true,
    modifyVars: {
      "@primary-color": "#1DA57A", // for example, you use Ant Design to change theme color.
    },
    cssLoaderOptions: {}, // .less file used css-loader option, not all CSS file.
    cssModules: {
      localIdentName: "[path][name]__[local]--[hash:base64:5]", // if you use CSS Modules, and custom `localIdentName`, default is '[local]--[hash:base64:5]'.
    },
  })
);
